<?php
session_start();
if ($_SESSION['sitecheck'] != "ok") die ("Unauthorized access!");
// Variables: successurl, failurl, antispamquery, antispam, domain, user, subject, prefix, postfix
$ignorelist = 'successurl|failurl|antispamquery|antispam|domain|user|subject|prefix|postfix';
$successurl = $_POST['successurl'];
$failurl = $_POST['failurl'];
$antispamquery = $_POST['antispamquery'];
$antispam = $_POST['antispam'];
$domain = $_POST['domain'];
$user = $_POST['user'];
$subject = $_POST['subject'];
$prefix = $_POST['prefix'];
$postfix = $_POST['postfix'];

if ($antispamquery != $antispam)
{
	header("Location: $failurl");
	die('');
}

$email = "$user@$domain";
$fieldlist = '';
foreach ($_POST as $key => $value)
{
	if (strpos($ignorelist, $key) === false)
	{
		$fieldlist .= "$key: $value\n";
	}
}

$content = "$prefix\n\n$fieldlist\n$postfix";

if (mail($email, $subject, $content, "From: Malpertuus Website <info@malpertuusgodsheide.be>"))
{
	header("Location: $successurl");
}
else
{
	header("Location: $failurl");
}

?>